import axios from 'axios'
axios.defaults.baseURL = 'http://shop.aixinjituan.com/Api/shop/'
function getCookie (name) {
  var arr = decodeURIComponent(document.cookie).split(' ')
  for (var i = 0; i < arr.length; i++) {
    var tmpStr = arr[i]
    var cookieName = tmpStr.split('=')[0]
    var cookieValue = tmpStr.split('=')[1]
    if (cookieName === name) {
      return cookieValue
    }
  }
}
export function apiPost(url,param,success){
  param.uid = getCookie('uid') === undefined ? undefined : getCookie('uid').split(';')[0]
  param.token =  getCookie('token') === undefined ? undefined : getCookie('token').split(';')[0]
       return axios.post(`${url}`,param).then((data) => {
         return data.data
       }).catch ((error)=> {
         return error
       })
  }

